package eerbaar.expression.internal.lib;

import eerbaar.context.IContext;
import eerbaar.context.IParams;
import eerbaar.context.ParamFactory;
import eerbaar.expression.IExpression;

public class OrExpression extends AbstractExpression {

    public OrExpression() {
        super("or");
    }

    @Override
    public boolean execute(IContext model) {

        boolean result = false;

        IExpression[] array = super.getExpressions();
        for (IExpression a : array) {

            result = a.execute(model);
            if (result == true) {
                break;
            }

        }

        return result;
    }

    @Override
    public String[] getParamNames() {
        return new String[] {};
    }

    @Override
    public IParams getParams() {
        return ParamFactory.createParams();
    }

    @Override
    public void setParams(IParams params) {
        //
    }

    @Override
    public void start() {

        IExpression[] array = super.getExpressions();
        for (IExpression e : array) {
            e.start();
        }
    }

    @Override
    public void stop() {

        IExpression[] array = super.getExpressions();
        for (IExpression e : array) {
            e.stop();
        }
    }

}
